

/**
 * 类型别名
 */

// type num = number

// let a:num ;
// a = "abc"


/**
 * 定义一个信息 既可以是 字符串  也可以是数字的
 */


//联合类型 string|number

type myInfoType = string | number
let info: myInfoType;

info = "100岁"
info = 100;
// info = true



//定义一个变量 性别
// let  gender:string = "男性"
// gender = "女性"
// gender = "男"

//字面量的联合类型
let gender: '男' | '女';
gender = '男'
gender = '女'
//报错
// gender = '男士'





//交叉类型
type BaseInfo = {
  name: string;
  age: number;
}

type Address = {
  provice: string;
  city: string;
  code?: number;

}


type UnionUser = BaseInfo & Address


let user1: UnionUser = {
  name: "张三",
  age: 18,
  provice: "黑龙江",
  city: "哈尔滨",
  code: 150001
}

let user2: UnionUser = {
  name: "张三",
  age: 18,
  provice: "黑龙江",
  city: "哈尔滨"

}









